/*******************************************
 * Copyright 2007 Aphrodite Framework for javaME .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * Email : owner@aphroditeme.dev.java.net
 * Contributors:
 *     Kent Elton - initial API and implementation
 *******************************************/

package com.aphrodite.ui.bg;

import javax.microedition.lcdui.Graphics;

import com.aphrodite.ui.graphics.Gradient;
import com.aphrodite.ui.graphics.GraphicEffects;

/**
 * <p>
 * GradientBackground for widgets.
 * </p>
 * 
 * @author kentelt
 * 
 */
public class GradientBackground extends Background {

	private Gradient gradient;

	public GradientBackground() {
		this(new Gradient());
	}

	/**
	 * 
	 * @param startcolor
	 *            of the Gradient
	 * @param endcolor
	 *            of the Gradient
	 * @throws IllegalArgumentException
	 *             if <code> startColor </code>and <code>endColor</code> are the
	 *             same
	 */
	public GradientBackground(Gradient gradient) {
		// super(0, 0, 0, 0, true);
		super();
		this.gradient = gradient;
	}

	public void render(Graphics g) {
		GraphicEffects.drawGradient(g, gradient, x, y, width, height);
	}

	/**
	 * 
	 * @param startColor
	 * @param endColor
	 * @throws IllegalArgumentException
	 *             if <code> startColor </code>and <code>endColor</code> are the
	 *             same
	 */
	public void setGradient(Gradient gradient) {
		this.gradient = gradient;

	}

}
